//
//  FOutlineView.h
//  SolarSeek
//
//  Created by Erick Fejta on 05/03/22.
//  Copyright 2005 Erick Fejta. All rights reserved.
//

#import <Cocoa/Cocoa.h>

/*
typedef enum { 
	FOutlineViewElementDefaultStateNone=0,
	FOutlineViewElementDefaultStateChildren = 1, 
	FOutlineViewElementDefaultStateExpand = 2, 
	FOutlineViewElementDefaultStateStateExpandAndExpandChildren = 3,
	FOutlineViewElementDefaultStateCollapse = 4,
	FOutlineViewElementDefaultStateCollapseAndCollapseChildren = 5
} OutlineViewElementDefaultState;
*/

@protocol FOutlineViewElement <NSObject>
- (NSArray *)children;			//access to the children.
- (BOOL)expandable;				//can we expand this item?
- (id<FOutlineViewElement>)item;	//default item to display.
//- (OutlineViewElementDefaultState)stateDefault;	//default state when added the first time.
@end

@interface FOutlineViewElement : NSObject <FOutlineViewElement> {}
- (NSArray *)children;	//returns an empty array.
- (BOOL)expandable;		//returns true if [[self children] count] > 0
- (id<FOutlineViewElement>)item;				//returns self by default
//- (OutlineViewElementDefaultState)stateDefault;	//no default state set.
@end

@interface FOutlineViewArrayElement : FOutlineViewElement {
	NSMutableArray *_children;
}

- (NSArray *)children;
- (void)insertObject:(id)o inChildrenAtIndex:(unsigned)index;
- (void)removeObjectFromChildrenAtIndex:(unsigned)index;

- (void)addElement:(id)element;
- (void)addElements:(NSArray *)elements;
- (void)removeElement:(id)element;
- (void)removeElements:(NSArray *)elements;
@end


@interface FOutlineViewDataSource : NSObject {
	IBOutlet id<FOutlineViewElement> _root;
}

- (id)initWithRoot:(id<FOutlineViewElement>)root;
- (id)initWithRoot:(id<FOutlineViewElement>)root outlineView:(NSOutlineView *)outlineView;

- (void)setRoot:(id<FOutlineViewElement>)root;
- (id<FOutlineViewElement>)root;

- (void)installOnOutlineView:(NSOutlineView *)outlineView;
- (void)uninstallFromOutlineView:(NSOutlineView *)outlineView;

- (void)setTableColumn:(NSTableColumn *)tableColumn performsSelector:(SEL)selector;
- (void)setOutlineView:(NSOutlineView *)outineView tableColumnNumber:(unsigned)num performsSelector:(SEL)selector;
@end
